﻿using System.Text.Json;

namespace OrderingFoot.Core.Tool
{
    /// <summary>
    /// json tool
    /// </summary>
    public class JsonTool
    {
        /// <summary>
        /// json 序列化
        /// </summary>
        public static string JsonSerialize(object obj)
        {
            return JsonSerializer.Serialize(obj, new JsonSerializerOptions { WriteIndented = false, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });
        }

        /// <summary>
        /// json反序列化
        /// </summary>
        public static T JsonDeserialize<T>(string json)
        {
            return JsonSerializer.Deserialize<T>(json);
        }
    }
}
